package com.exam.Exception;

import com.exam.common.Result;
import org.apache.commons.mail.EmailException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @Description 全局异常处理
 * @Date 2023/2/8
 * @Author ChengKe
 */


@ResponseBody
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(ExamException.class)
    public Result exception(ExamException e){
        return Result.failed(e.getMessage());
    }

    @ExceptionHandler(EmailException.class)
    public Result exception(EmailException e){

        return Result.failed(e.getMessage());
    }

}
